package ltd.dujiabao.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author : DuJiabao
 * @Project : springcloud
 * @Time : 2021/5/23 11:16
 * @Desc :
 */
@Configuration
@SuppressWarnings("all")  // 明明可以autowired，告诉我找不到，我直接抑制你warning
public class GateWayConfig {
  @Bean
  public RouteLocator routeLocator1(RouteLocatorBuilder builder) {
    RouteLocatorBuilder.Builder routes = builder.routes();
    return routes.route("new_guonei", r -> r.path("/guonei").uri("http://news.baidu.com/guonei")).build();
  }

  @Bean
  public RouteLocator routeLocator2(RouteLocatorBuilder builder) {
    RouteLocatorBuilder.Builder routes = builder.routes();
    return routes.route("new_guoji", r -> r.path("/guoji").uri("http://news.baidu.com/guoji")).build();
  }
}
